package top.wshape1.rpc.test.demo1;

import top.wshape1.rpc.JJRPC;
import top.wshape1.rpc.common.constant.FaultTolerantEnum;
import top.wshape1.rpc.config.RegistryConfig;
import top.wshape1.rpc.model.User;
import top.wshape1.rpc.service.HelloService;
import top.wshape1.rpc.test.demo1.service.HelloServiceImpl;

import java.io.IOException;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2024-02-20
 */

public class Demo1 {

    public static void main(String[] args) throws IOException {
        JJRPC jjrpc = new JJRPC()
                .consumer(true)
                .provider(true)
                .serviceHost("localhost")
                .servicePort(7001)
                .zookeeperRegistry(new RegistryConfig.ZookeeperRegistryConfig("192.168.245.128:2181"))
                .faultTolerant(FaultTolerantEnum.failfast)
                .start();


        jjrpc.registerService(HelloService.class, new HelloServiceImpl());

        HelloService service = jjrpc.getService(HelloService.class);

        int read = System.in.read();

        System.out.println(service.sayHello(new User("wshape1", 20, 1, "beijing")));

    }

}
